class Solution{
public:
  bool isSymmetric(TreeNode *root){

    return judge(root, root);

  }

  bool judge(TreeNode *left, TreeNode *right){

    if(!left && !right){
      return true;
    }else if(!left && right || left && !right){
      return false;
    }else if(left->val == right->val){
      return judge(left->left, right->right) && judge(left->right, right->left);
    }

    return false;

  }
};